package net.tensor.skynet.api.controller.user

import net.tensor.skynet.api.base.PageResult
import net.tensor.skynet.api.service.user.UserService
import net.tensor.skynet.common.user.entity.User
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.mongodb.core.query.Query
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/user/queryPage")
class UserQueryPageController {

    @Autowired
    private lateinit var userService: UserService


    @PostMapping
    fun invoke(@RequestBody param:Map<String,Int>): PageResult<User> {
        val pageSize= requireNotNull(param["pageSize"]) {" non "}
        val page= requireNotNull(param["page"]) {" non "}
        return userService.queryPage(pageSize,page, Query())
    }

    data class QueryPageParam(
         var page:Int,
         var pageSize: Int
    )

}